import { fetchData,postData,delData,putData } from '../../api/index';

export default function(){
    let receipt_url = "/api/service/receipt"
    let return_url = "/api/service/return"
    let receipt_query_url = "/api/service/receipt/query"
    let receipt_recheck_url = "/api/service/receipt/recheck"
    let getReceipt= async () => {
        try {
            const res = await fetchData(receipt_url);
            return res
        } catch (error) {
        }
    }
    let postReceiptAction = <T>(data:T,action:string) => {
        try {
            const res = postData(receipt_url + "/" + action,data)
            return res
        } catch (error) {

        }
    }
    let queryReceiptProject = async <T>(query:T) => {
        try{
            const res = await postData(receipt_query_url,query);
            return res
        } catch (error) {

        }
    }
    let postReceiptRecheck = async <T>(data:T,action:string) => {
        try {
            const res = await postData(receipt_recheck_url + "/" + action,data)
            return res
        } catch (error) {

        }
    } 
    let postReturn = async <T>(data:T) => {
        try{
            const res = await postData(return_url,data)
            return res
        } catch (error){

        }
    }
    let editReceipt = async <T>(data:T,id:number) => {
        try {
            const res = await putData(receipt_url + "/" + id,data)
            return res
        } catch (error) {

        }
    }
    return { getReceipt,queryReceiptProject,postReceiptAction,postReturn,postReceiptRecheck,editReceipt }
}